package de.kardass.jannobatch.skiprepeatabort;

import de.kardass.jannobatch.ItemProcessorAdapter;

public class StepOne extends ItemProcessorAdapter<WorkflowItem, WorkflowItem> {

    @Override
    public WorkflowItem process(WorkflowItem item) {
        item.setCounter(item.getCounter() + 1);
        switch (item.getId()) {
            case 0:
                return item;
            case 1:
                if (item.getCounter() == 1) {
                    throw new RepeatFirstStepException(item);
                } else {
                    item.incRepeatCounter();
                    return item;
                }
            case 2:
                item.incSkipStepCounter();
                throw new SkipFirstStepException(item);
            case 3:
                item.incSkipItemCounter();
                throw new SkipItemException(item);
            case 4:
                throw new AbortJobException(item);
            default:
                throw new IllegalStateException("Should reach this position for item: " + item);
        }
    }

    
}
